#ifndef GAMEENGINE_GEOMETRY_POINT2D_H
#define GAMEENGINE_GEOMETRY_POINT2D_H

#include <GameEngine/Geometry/geometry_settings.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

template <class T> class Vector2d;

namespace Point2D {
	//! Coordinate index for a two-dimensional point
	enum Index {
		//! First coordinate (aka 'x')
		First = 0,
		//! Second coordinate (aka 'y')
		Second = 1
	};
}



//! Class used to represent 2D points
/*!
 @note A 2D point is made of two coordinates, typically
       named x and y. The coordinates are of type T,
	   which allows client code to choose the level of
	   precision (typically, T will be either float or
	   double)
 @todo Setup unit tests
 @sa The Point3d class that handles 3D points, and the Vector2d class that
     handles 2D vectors.
 */
template <class T>
class Point2d {

public:
	Point2d();
	Point2d(const T& x, const T& y);
	Point2d(const Point2d& rhs);
	template <class R> Point2d(const Point2d<R>& rhs);
	virtual ~Point2d();
	Point2d& operator=(const Point2d& rhs);

	T& x();
	const T& x() const;
	T& y();
	const T& y() const;

	T& operator[](Point2D::Index index);
	const T& operator[](Point2D::Index index) const;

	double get_distance(const Point2d& rhs) const;
	T get_square_distance(const Point2d& rhs) const;

protected:
	//! Point coordinates
	T coordinates_[2];
};

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#include <GameEngine/Geometry/Location/point2d.hpp>

#endif
